package com.powermgr.boringtest.controller;

import com.powermgr.boringtest.result.Result;
import com.powermgr.boringtest.service.IDownLoadService;
import com.powermgr.boringtest.service.IStartService;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * TestWorkController
 *
 * @author qiuxiangdong
 * @date 2023/6/12
 */
@RestController
@Log4j2
public class TestWorkController {
    @Resource
    private IStartService startService;

    @Resource
    private IDownLoadService downLoadService;

    @CrossOrigin
    @RequestMapping(value = "status", method = RequestMethod.GET)
    public Result<Object> state() {
        return startService.getList();
    }

    @GetMapping("/download")
    public void download(@RequestParam("reports") String path, HttpServletResponse response) {
        downLoadService.downLoad(path, response);
    }
}
